<script lang="ts" setup>
import { ref, onUpdated } from 'vue';
import { tabProps, tabEmits } from './tab';
defineOptions({ name: 'WindowsTaskbar' });
const props = defineProps(tabProps);
const emits = defineEmits(tabEmits);
const select = ref(false);
const handleTabClick = () => {
  select.value = true;
  emits('tab-click', window.name);
};
onUpdated(() => {});
</script>

<template>
  <div :class="[select ? 'select' : '', 'windows-tab']" @click="handleTabClick">
    <el-image style="width: 20px" :src="window.icon" fit="contain" />
    <span v-if="window.label">{{ window.label }}</span>
  </div>
</template>

<style lang="scss" scoped>
.windows-tab {
  height: 40px;
  min-width: 25px;
  padding: 0px 5px;
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  user-select: none;
  &:hover,
  &.select {
    background: rgba(220, 220, 220, 0.15);
  }
  :last-child {
    margin-right: 0px;
  }
  & > span {
    margin-left: 5px;
    font-size: 12px;
  }
}
</style>
